package utils

import (
	"crypto/md5"
	"encoding/hex"
	"crypto/sha1"
	"io"
	"fmt"
)

func StringMd5(str string) string {
	hash := md5.New()
	hash.Write([]byte(str))

	return hex.EncodeToString(hash.Sum(nil))
}

//对字符串进行SHA1哈希
func StringSHA1(str string) string {
	t := sha1.New();
	io.WriteString(t, str);
	return fmt.Sprintf("%x", t.Sum(nil));
}
